import pandas
import matplotlib.pyplot as plt

dataset = 'sift'
ef_construction = '100'
top_k = 10
method_l = ['baseline', 'serial_shuffle']
m_l = ['40', '48']
method_name_l = ['baseline', 'serial_shuffle']
dir_arr = []
for i in range(len(method_l)):
    # tmp_dir = "result/{}_{}_{}_{}_{}/time-recall.csv".format(dataset, top_k, method_l[i], m_l[i], ef_construction)
    tmp_dir = "result/{}_{}_{}_{}/time-recall.csv".format(dataset, method_l[i], m_l[i], ef_construction)
    dir_arr.append(tmp_dir)
    print(tmp_dir)

df_l = []
for dire in dir_arr:
    tmp_df = pandas.read_csv(dire, skipinitialspace=True)
    tmp_df = tmp_df.rename(columns={'time-per-query(ms)': 'time'})
    df_l.append(tmp_df)

# marker
# o 圆圈, v 倒三角, ^ 正三角, < 左三角, > 右三角, 8 大圆圈, s 正方形, p 圆圈, * 星号, h 菱形, H 六面体, D 大菱形, d 瘦的菱形, P 加号, X 乘号
# 紫色#b9529f 蓝色#3953a4 红色#ed2024 #231f20 深绿色#098140 浅绿色#7f8133 #0084ff
# solid dotted

marker_l = ['H', 'D', 'P', '>', '*', 'X', 's', '<', '^', 'p', 'v']
color_l = ['#b9529f', '#3953a4', '#ed2024', '#098140', '#231f20', '#7f8133', '#0084ff']

for i, method in enumerate(method_l):
    # 第一个是横坐标的值，第二个是纵坐标的值
    plt.plot(df_l[i]['time'], df_l[i]['recall'], marker=marker_l[i], linestyle='solid',
             color=color_l[i],
             label=method_name_l[i])

# plt.xscale('log')

# plt.title('graph kmeans vs knn')
title_ds_name = '%s1M, M=40, efConstruction=100, efSearch=[50, 70, 90, 110, 130]' % dataset
plt.legend(loc='lower right', title="%s, top-10" % title_ds_name)

plt.xlabel("Time(ms)")
plt.ylabel("Recall")
plt.grid(True, linestyle='-.')
plt.show()
# plt.close()
